﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using GalaSoft.MvvmLight.Messaging;
using ViewModel.Rss;
using GalaSoft.MvvmLight.Command;
using serviceMaker.RssService;

namespace EPIClientRssWP7.WP7ViewModel
{
    public class WP7RssViewModel : RssViewModel
    {

        public WP7RssViewModel()
        {
            CommandSelectRss = new RelayCommand<SelectionChangedEventArgs>(SelectedItemCommand, CanSelectedItemCommand);
  //          GoToAddRss = new RelayCommand(ExecuteGoToAdd, CanExecuteGoToAdd);
        }

        #region Command
        public ICommand CommandSelectRss { get; set; }

        private void SelectedItemCommand(SelectionChangedEventArgs arg)
        {
            if (arg != null && arg.AddedItems.Count > 0 && arg.AddedItems[0] is DataRss)
            {
                this.RssSelected = arg.AddedItems[0] as DataRss;
                Uri uri = new Uri("/View/ItemRssListView.xaml", UriKind.Relative);
                Messenger.Default.Send<Uri>(uri, "NavigationRequest");
            }
            else if (arg != null && arg.AddedItems.Count > 0 && arg.AddedItems[0] is DataItem)
            {
                this.RssSelected = arg.AddedItems[0] as DataRss;
                Uri uri = new Uri("/View/ItemRssView.xaml", UriKind.Relative);
                Messenger.Default.Send<Uri>(uri, "NavigationItemChosen");
            }
        }

        public bool CanSelectedItemCommand(SelectionChangedEventArgs arg)
        {
            return true;
        }


      

        #endregion

        //#region CommandRssManagement
        //public ICommand GoToAddRss
        //{ get; set; }


        //private void ExecuteGoToAdd()
        //{
        //    Messenger.Default.Send<Uri>(new Uri("/View/AddRssView.xaml"), "GoToAdd");
        //}

        //private bool CanExecuteGoToAdd()
        //{
        //    return true;
        //}

        //#endregion
    }
}
